package com.sikao.app.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.sikao.app.R;
import com.sikao.app.bean.EntrustListBean;
import com.sikao.app.net.HttpApi;
import com.sikao.app.ui.base.BaseActivity;
import com.sikao.app.utils.TimeUtil;

/**
 * 委托详情页
 */
public class EntrustDetailsActivity extends BaseActivity implements View.OnClickListener {

	private TextView titleTv;
	private ImageView backIv;
	private EntrustListBean.ResBean.ListBean bean;
	private TextView themeTv;
	private TextView phoneTv;
	private TextView timeTv;
	private ImageView iv;
	private TextView contentTv;
	public static final String ENTRUST_DETAILS = "entrustDetails";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_entrust_details);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void initData() {
		bean = getIntent().getParcelableExtra(ENTRUST_DETAILS);
	}

	@Override
	protected void initView() {
		titleTv = (TextView) findViewById(R.id.title_middle_tv);
		backIv = (ImageView) findViewById(R.id.title_left_img);
		themeTv = (TextView) findViewById(R.id.theme_tv);
		phoneTv = (TextView) findViewById(R.id.phone_tv);
		timeTv = (TextView) findViewById(R.id.time_tv);
		iv = (ImageView) findViewById(R.id.iv);
		contentTv = (TextView) findViewById(R.id.content_tv);
	}

	@Override
	protected void initListener() {
		backIv.setOnClickListener(this);
	}

	@Override
	protected void init() {
		titleTv.setText("委托详情");
		backIv.setVisibility(View.VISIBLE);
		themeTv.setText(bean.getName());
		contentTv.setText(bean.getCont());
		timeTv.setText(TimeUtil.timeStampToTime(bean.getAdd_time(), TimeUtil.fotmatString2));
		phoneTv.setText(bean.getPhone());
		if (bean.getProfile_pic_url() != null && bean.getProfile_pic_url().size() != 0) {
			ImageLoader.getInstance().displayImage(HttpApi.BANNERUTL + bean.getProfile_pic_url().get(0).getUrl(), iv);
		} else {
			iv.setVisibility(View.GONE);
		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.title_left_img:
				finish();
				break;
			default:
				break;
		}
	}

}
